<template>
	<view>
		<view class="user">
			<image class="back_ground" src="../../static/images/background.png" mode=""></image>
			<view class="user_main">
				<view class="user-top">
					<view class="userinfo" v-if="isLogin" @click="$u.route('/pagesUser/userinfo/userinfo')">
						<u-avatar mode="circle" size="150" :src="userInfo.avatar"></u-avatar>
						<view class="info">
							<text>{{userInfo.nickname}}</text>
							<view class="vip">
								<image src="../../static/images/VIP1.png" mode="" style="width: 40rpx;height: 40rpx;">
								</image>
								<text class="viptext">{{userVip.name}}</text>
							</view>
						</view>
					</view>
					<view class="userinfo" v-else @click="$u.route('/pages/login/login')">
						<u-avatar mode="circle" size="150" :src="avatar">
						</u-avatar>
						<view class="info">
							<text style="color: #fff;">您还未登录哦</text>
						</view>
					</view>
					<view class="sigin"  @click="navTo('/pagesUser/userinfo/userinfo',true)">
						<u-icon name="edit-pen" color="#00CE41" size="28"></u-icon>
						<text style="margin-left: 10rpx;">编辑</text>
					</view>
				</view>
				<view class="user_num">
					<image src="../../static/images/num_background.png" mode=""></image>
					<view class="num_txt">
						<view class="grid-text">钱包</view>
						<text>22</text>
					</view>
					<view class="num_txt" @click="navTo('/pagesUser/collect/collect',true)">
						<view class="grid-text">收藏</view>
						<text>22</text>
					</view>
				</view>
			</view>
		</view>
		<view class="menu">
			<text class="menu-title">我的功能</text>
			<u-grid :col="4" :border="false">
				<u-grid-item @click="navTo('/pagesUser/push/push',true)">
					<view class="gird">
						<u-image width="60rpx" height="60rpx" src="@/static/images/user_menu12.png"></u-image>
						<view class="grid-text">我的发布</view>
					</view>
				</u-grid-item>
				<u-grid-item @click="navTo('/pagesUser/resume/resume',true)">
					<view class="gird">
						<u-image width="60rpx" height="60rpx" src="@/static/images/user_menu13.png"></u-image>
						<view class="grid-text">我的简历</view>
					</view>
				</u-grid-item>
				<u-grid-item @click="navTo('/pagesUser/collect/collect',true)">
					<view class="gird">
						<u-image width="60rpx" height="60rpx" src="@/static/images/menu14.png"></u-image>
						<view class="grid-text">我的收藏</view>
					</view>
				</u-grid-item>
				<u-grid-item @click="navTo('/pagesFind/store_center/store_center',true)">
					<view class="gird">
						<u-image width="60rpx" height="60rpx" src="@/static/images/user_menu15.png"></u-image>
						<view class="grid-text">我的店铺</view>
					</view>
				</u-grid-item>
				<!-- <u-grid-item @click="navTo('/pagesUser/msg/msg')">
					<view class="gird">
						<u-image width="60rpx" height="60rpx" src="@/static/images/menu1.png"></u-image>
						<view class="grid-text">我的消息</view>
					</view>
				</u-grid-item> -->
			</u-grid>
		</view>
		<view class="menu">
			<text class="menu-title">工具与服务</text>
			<u-grid :col="4" :border="false">
				<u-grid-item v-if="opentop" @click="navTo('/pagesUser/vip/vip',true)">
					<view class="gird">
						<u-image width="60rpx" height="60rpx" src="@/static/images/vip.png"></u-image>
						<view class="grid-text">我的会员</view>
					</view>
				</u-grid-item>
				<u-grid-item>
					<!--#ifdef MP-WEIXIN-->
					<button class="concat" hover-class='none' open-type="contact">
						<u-image width="60rpx" height="60rpx"
							src="@/static/images/user_menu16.png"></u-image>
						<view class="grid-text">联系客服</view>
					</button>
					<!--#endif-->
					<!--#ifndef MP-WEIXIN-->
					<view class="gird" @click="callContact">
						<u-image width="60rpx" height="60rpx" src="@/static/images/user_menu16.png"></u-image>
						<view class="grid-text">联系客服</view>
					</view>
					<!--#endif-->
				</u-grid-item>
				<u-grid-item @click="navTo('/pagesUser/help/help',false)">
					<view class="gird">
						<u-image width="60rpx" height="60rpx" src="@/static/images/user_menu17.png"></u-image>
						<view class="grid-text">帮助中心</view>
					</view>
				</u-grid-item>
				<u-grid-item @click="navTo('/pagesUser/feedback/feedback',true)">
					<view class="gird">
						<u-image width="60rpx" height="60rpx" src="@/static/images/menu18.png"></u-image>
						<view class="grid-text">意见反馈</view>
					</view>
				</u-grid-item>
				<u-grid-item>
					<!--#ifdef MP-WEIXIN-->
					<button class="concat" hover-class='none' open-type="share">
						<u-image width="60rpx" height="60rpx"
							src="@/static/images/menu19.png"></u-image>
						<view class="grid-text">邀请好友</view>
					</button>
					<!--#endif-->
					<!--#ifndef MP-WEIXIN-->
					<view class="gird">
						<u-image width="60rpx" height="60rpx" src="@/static/images/menu19.png"></u-image>
						<view class="grid-text">邀请好友</view>
					</view>
					<!--#endif-->
				</u-grid-item>
				<u-grid-item @click="navTo('/pagesUser/setting/setting',false)">
					<view class="gird">
						<u-image width="60rpx" height="60rpx" src="@/static/images/menu20.png"></u-image>
						<view class="grid-text">系统设置</view>
					</view>
				</u-grid-item>
			</u-grid>
		</view>
	</view>
</template>

<script>
	import {
		mapActions,
		mapState
	} from 'vuex'
	import {
		APP_MOBILE,
		APP_NAME
	} from '../../env.js'
	export default {
		data() {
			return {
				avatar:require('../../static/images/headerImage.png'),
				userVip: {
					vip_id: 1,
					vip_time: 0,
					name: "普通会员"
				},
				opentop:false,
			}
		},
		computed: {
			...mapState({
				userInfo: state => state.user.userInfo,
				isLogin: state => state.user.isLogin,
			})
		},
		onLoad() {
			this.getVerify()
		},
		onShow() {
			if (this.isLogin) {
				this.$u.get('/addons/hicity/user/getUserVip', {

				}).then(res => {
					this.userVip = res
				})
			}
		},
		onShareAppMessage() {
			return {
				title: APP_NAME,
				path: '/pages/index/index'
			}
		},
		methods: {
			getVerify() {
				this.$u.get('/addons/hicity/index/getVerify', {}).then(res => {
					this.opentop = res.opentop;
				})
			},
			navTo(path, toLogin) {
				if (toLogin) {
					if (this.isLogin) {
						this.$u.route(path)
					} else {
						this.$u.route('/pages/login/login')
					}

				} else {
					this.$u.route(path)
				}
			},
			callContact() {
				uni.makePhoneCall({
					phoneNumber: APP_MOBILE
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.user {
		background-color: white;
		position: relative;
		
		.back_ground{
			position: absolute;
			top: 0;
			left: 0;
			z-index: 1;
			display: block;
			width: 100%;
			height: 100%;
		}
		.user_main{
			position: relative;
			z-index: 2;
		}
		.user-top {
			padding: 30rpx;
			display: flex;
			flex-direction: row;
			align-items: center;
			justify-content: space-between;

			.userinfo {
				display: flex;
				flex-direction: row;
				align-items: center;

				.info {
					margin-left: 20rpx;
					color: #fff;
					font-weight: 600;
					font-size: 35rpx;
					word-break: break-all;
					display: -webkit-box;
					-webkit-line-clamp: 2;
					-webkit-box-orient: vertical;
					overflow: hidden;
					margin-right: 20rpx;

					.vip {
						display: flex;
						flex-direction: row;
						align-items: center;
						font-size: 24rpx;
						margin-top: 15rpx;

						.viptext {
							margin-left: 10rpx;
							color: #fff;
							font-weight: normal;
						}
					}
				}
			}

			.sigin {
				background-color: #fff;
				margin-right: -30rpx;
				border-top-left-radius: 30rpx;
				border-bottom-left-radius: 30rpx;
				color: #00CE41;
				height: 50rpx;
				width: 150rpx;
				display: flex;
				flex-direction: row;
				align-items: center;
				justify-content: center;
			}
		}
		.user_num{
			position: relative;
			width: 690rpx;
			height: 200rpx;
			padding: 40rpx 0;
			margin: 20rpx auto 10rpx;
			display: flex;
			image{
				position: absolute;
				top: 0;
				left: 0;
				z-index: 1;
				display: block;
				width: 100%;
				height: 100%;
			}
			.num_txt{
				position: relative;
				z-index: 2;
				width: 50%;
				height: 100%;
				padding-left: 50rpx;
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				.grid-text{
					font-size: 30rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #FFFFFF;
				}
				text{
					padding-top: 10rpx;
					font-size: 60rpx;
					font-family: PingFang SC;
					font-weight: bold;
					color: #FFFFFF;
				}
			}
			.num_txt:last-child{
				padding-left: 70rpx;
				border-left: 1px solid #fff;
			}
		}
	}

	.menu {
		margin: 20rpx;
		background-color: white;
		padding: 20rpx 20rpx 0 20rpx;
		border-radius: 20rpx;

		.menu-title {
			font-size: 32rpx;
			color: #666666;
			padding-bottom: 20rpx;
		}
	}

	.gird {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		color: #333333;
		
		.grid-text{
			height: 50rpx;
			line-height: 50rpx;
		}
		
	}

	.concat {
		font-size: 28rpx;
		background-color: white;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		padding: 0;
		margin: 0;
		width: 100%;
		line-height: 50rpx;
		overflow: hidden;
		color: #333333;
	}

	.concat::after {
		border: none;
	}
</style>
